<?php

namespace plugin\admin\app\model;

use plugin\admin\app\model\Base;

/**
 * @property integer $id (主键)
 * @property string $name 中文通道名称
 * @property string $en_name 英文通道名称
 * @property integer $parent_id 父通道ID
 */
class ChannelName extends Base
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'wa_channel_names';

    /**
     * The primary key associated with the table.
     *
     * @var string
     */
    protected $primaryKey = 'id';
    /**
     * Indicates if the model should be timestamped.
     *
     * @var bool
     */
    public $timestamps = false;

    /**
     * 获取父通道
     */
    public function parent()
    {
        return $this->belongsTo(ChannelName::class, 'parent_id', 'id');
    }

    /**
     * 获取子通道
     */
    public function children()
    {
        return $this->hasMany(ChannelName::class, 'parent_id', 'id');
    }
    
}